<?php

namespace App\Http\Controllers\Home\Wechat;

use Illuminate\Http\Request;

use App\Http\Requests;
//use App\Http\Controllers\Controller;
use App\Models\wechat\Ad;
use App\Models\shop\Product;

class IndexController extends CommonController
{

    public function __construct()
    {
//        parent::__construct();
        view()->share([
            '_index' => 'on'
        ]);
    }

    //显示微信商城首页
    public function index()
    {
        $sliders=Ad::where('category_id','1')->get();  //大图轮播
        $banners=Ad::where('category_id','2')->get();  //小图显示

        //首页推荐商品  上架 is_top 按创建时间降序 取5条
        $products=Product::where('is_onsale','1')->orderBy('is_top','desc')->orderBy('created_at','desc')->take(5)->get();  //产品展示
        return view('home.wechat.index')->with('sliders',$sliders)->with('banners',$banners)->with('products',$products);
    }
    
    //
    
}
